#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	int n;scanf("%d",&n);
	std::vector<int> v(n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&v[i]);
	}
	std::vector<int> status(n);
	status[0]=0;
	for (int i = 1; i < n; ++i)
	{
		if(v[i]>v[i-1]){
			status[i]=1;
		}else{
			status[i]=-1;
		}
	}
	int ans=0;
	for (int i = 2; i < n; ++i)
	{
		if(status[i]!=status[i-1]){
			++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}